<template>
  <div class="login">
    <!--title对话框左上角标题 v-model控制对话框显示与隐藏-->
    <el-dialog v-model="userStore.visiable" title="用户登陆">
      <div class="content">
        <el-row>
          <el-col :span="12">
            <div v-show="scene == 0" class="loginDiv">
              <el-form :model="loginParam" :rules="rules" ref="form">
                <el-form-item prop="phone">
                  <el-input v-model="loginParam.phone" placeholder="请输入用户名" :prefix-icon="User"></el-input>
                </el-form-item>
                <el-form-item prop="code">
                  <el-input v-model="loginParam.code" placeholder="请输入验证码" :prefix-icon="Lock"></el-input>
                </el-form-item>
                <el-form-item>
                  <el-button :disabled="!isPhone || codeFlag" @click="getCode">
                    <span v-if="!codeFlag">获取验证码</span>
                    <CountDown v-else :codeFlag="codeFlag" @getCodeFlag="getCodeFlag"/>
                  </el-button>
                </el-form-item>
              </el-form>
              <el-button style="width: 90%" type="primary" size="default"
                         :disabled="!isPhone || loginParam.code.length != 6" @click="phoneLoginSubmit">用户登陆
              </el-button>
              <div class="bottom" @click="changeScene(1)">
                <p>微信扫码登陆</p>
                <svg t="1730292987988" class="icon" viewBox="0 0 1024 1024" version="1.1"
                     xmlns="http://www.w3.org/2000/svg" p-id="1514" width="32" height="32">
                  <path
                      d="M337.387283 341.82659c-17.757225 0-35.514451 11.83815-35.514451 29.595375s17.757225 29.595376 35.514451 29.595376 29.595376-11.83815 29.595376-29.595376c0-18.49711-11.83815-29.595376-29.595376-29.595375zM577.849711 513.479769c-11.83815 0-22.936416 12.578035-22.936416 23.6763 0 12.578035 11.83815 23.676301 22.936416 23.676301 17.757225 0 29.595376-11.83815 29.595376-23.676301s-11.83815-23.676301-29.595376-23.6763zM501.641618 401.017341c17.757225 0 29.595376-12.578035 29.595376-29.595376 0-17.757225-11.83815-29.595376-29.595376-29.595375s-35.514451 11.83815-35.51445 29.595375 17.757225 29.595376 35.51445 29.595376zM706.589595 513.479769c-11.83815 0-22.936416 12.578035-22.936416 23.6763 0 12.578035 11.83815 23.676301 22.936416 23.676301 17.757225 0 29.595376-11.83815 29.595376-23.676301s-11.83815-23.676301-29.595376-23.6763z"
                      fill="#1afa29" p-id="1515"></path>
                  <path
                      d="M510.520231 2.959538C228.624277 2.959538 0 231.583815 0 513.479769s228.624277 510.520231 510.520231 510.520231 510.520231-228.624277 510.520231-510.520231-228.624277-510.520231-510.520231-510.520231zM413.595376 644.439306c-29.595376 0-53.271676-5.919075-81.387284-12.578034l-81.387283 41.433526 22.936416-71.768786c-58.450867-41.433526-93.965318-95.445087-93.965317-159.815029 0-113.202312 105.803468-201.988439 233.803468-201.98844 114.682081 0 216.046243 71.028902 236.023121 166.473989-7.398844-0.739884-14.797688-1.479769-22.196532-1.479769-110.982659 1.479769-198.289017 85.086705-198.289017 188.67052 0 17.017341 2.959538 33.294798 7.398844 49.572255-7.398844 0.739884-15.537572 1.479769-22.936416 1.479768z m346.265896 82.867052l17.757225 59.190752-63.630058-35.514451c-22.936416 5.919075-46.612717 11.83815-70.289017 11.83815-111.722543 0-199.768786-76.947977-199.768786-172.393063-0.739884-94.705202 87.306358-171.653179 198.289017-171.65318 105.803468 0 199.028902 77.687861 199.028902 172.393064 0 53.271676-34.774566 100.624277-81.387283 136.138728z"
                      fill="#1afa29" p-id="1516"></path>
                </svg>
              </div>
            </div>
            <div v-show="scene == 1" class="wxDiv">
              <!--微信二维码-->
              <div id="login_container">

              </div>
              <div class="bottom" @click="changeScene(0)">
                <p>手机短信验证码登陆</p>
                <svg t="1730345274779" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4300" width="16" height="16"><path d="M512 832m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0Z" p-id="4301"></path><path d="M790.4 32H233.6C182.72 32 144 78.336 144 132.928v758.144C144 945.664 182.72 992 233.6 992h556.8c50.88 0 89.6-46.336 89.6-100.928V132.928C880 78.336 841.28 32 790.4 32zM233.6 96h556.8c12.736 0 25.6 15.392 25.6 36.928V160h-608v-27.072C208 111.392 220.864 96 233.6 96z m556.8 832H233.6c-12.736 0-25.6-15.392-25.6-36.928V224h608v667.072c0 21.536-12.864 36.928-25.6 36.928z" p-id="4302"></path><path d="M704 560H320a32 32 0 1 0 0 64h384a32 32 0 1 0 0-64zM320 432h256.576a32 32 0 1 0 0-64H320a32 32 0 0 0 0 64z" p-id="4303"></path></svg>
              </div>
            </div>
          </el-col>
          <el-col :span="12">
            <div class="leftContent">
              <div class="top">
                <div class="item">
                  <svg t="1730293352006" class="icon" viewBox="0 0 1024 1024" version="1.1"
                       xmlns="http://www.w3.org/2000/svg" p-id="2906" width="128" height="128">
                    <path
                        d="M433.282171 47.939849 94.944396 47.939849c-23.327288 0-42.304502 18.975167-42.304502 42.300408l0 338.341868c0 23.324218 18.977213 42.300408 42.304502 42.300408L433.282171 470.882534c23.324218 0 42.300408-18.97619 42.300408-42.300408L475.582579 90.240257C475.581556 66.915016 456.606389 47.939849 433.282171 47.939849zM438.742533 428.582125c0 3.01159-2.449795 5.461385-5.461385 5.461385L94.944396 434.04351c-3.013637 0-5.465478-2.450818-5.465478-5.461385L89.478917 90.240257c0-3.01159 2.451842-5.461385 5.465478-5.461385L433.282171 84.778872c3.01159 0 5.461385 2.449795 5.461385 5.461385L438.743556 428.582125z"
                        fill="#FF9000" p-id="2907"></path>
                    <path
                        d="M322.914504 173.887352l-117.608581 0c-14.733563 0-26.719548 11.985986-26.719548 26.719548l0 117.608581c0 14.735609 11.985986 26.724665 26.719548 26.724665l117.608581 0c14.735609 0 26.724665-11.989055 26.724665-26.724665l0-117.608581C349.640192 185.873338 337.651137 173.887352 322.914504 173.887352zM312.801169 308.101123l-97.374748 0 0-97.374748 97.374748 0L312.801169 308.101123z"
                        fill="#FF9000" p-id="2908"></path>
                    <path
                        d="M322.914504 675.606195l-117.608581 0c-14.733563 0-26.719548 11.989055-26.719548 26.724665l0 117.608581c0 14.732539 11.985986 26.719548 26.719548 26.719548l117.608581 0c14.735609 0 26.724665-11.987009 26.724665-26.719548l0-117.608581C349.640192 687.59525 337.651137 675.606195 322.914504 675.606195zM312.801169 809.819966l-97.374748 0 0-97.374748 97.374748 0L312.801169 809.819966z"
                        fill="#FF9000" p-id="2909"></path>
                    <path
                        d="M699.123818 344.940147l117.608581 0c14.735609 0 26.724665-11.989055 26.724665-26.724665l0-117.608581c0-14.733563-11.989055-26.719548-26.724665-26.719548l-117.608581 0c-14.732539 0-26.719548 11.985986-26.719548 26.719548l0 117.608581C672.40427 332.951091 684.391279 344.940147 699.123818 344.940147zM709.243293 210.726376l97.374748 0 0 97.374748-97.374748 0L709.243293 210.726376z"
                        fill="#FF9000" p-id="2910"></path>
                    <path
                        d="M433.282171 546.435277 94.944396 546.435277c-23.327288 0-42.304502 18.97619-42.304502 42.300408L52.639894 927.077553c0 23.325241 18.977213 42.301432 42.304502 42.301432L433.282171 969.378985c23.324218 0 42.300408-18.97619 42.300408-42.301432L475.582579 588.735685C475.581556 565.411467 456.606389 546.435277 433.282171 546.435277zM438.742533 927.077553c0 3.01159-2.449795 5.462408-5.461385 5.462408L94.944396 932.539962c-3.013637 0-5.465478-2.450818-5.465478-5.462408L89.478917 588.735685c0-3.010567 2.451842-5.461385 5.465478-5.461385L433.282171 583.2743c3.01159 0 5.461385 2.450818 5.461385 5.461385L438.743556 927.077553z"
                        fill="#FF9000" p-id="2911"></path>
                    <path
                        d="M590.849836 547.776831c-23.325241 0-42.301432 18.978237-42.301432 42.305525l0 194.649212c0 10.172687 8.246825 18.419512 18.419512 18.419512s18.419512-8.246825 18.419512-18.419512L585.387427 590.082356c0-3.013637 2.450818-5.466502 5.462408-5.466502l204.825992 0c10.172687 0 18.419512-8.246825 18.419512-18.419512s-8.246825-18.419512-18.419512-18.419512L590.849836 547.776831z"
                        fill="#FF9000" p-id="2912"></path>
                    <path
                        d="M588.757175 470.882534l338.341868 0c23.325241 0 42.301432-18.97619 42.301432-42.300408L969.400474 90.240257c0-23.324218-18.97619-42.300408-42.301432-42.300408L588.757175 47.939849c-23.324218 0-42.300408 18.975167-42.300408 42.300408l0 338.341868C546.456766 451.906343 565.432956 470.882534 588.757175 470.882534zM583.295789 90.240257c0-3.01159 2.450818-5.461385 5.461385-5.461385l338.341868 0c3.01159 0 5.462408 2.449795 5.462408 5.461385l0 338.341868c0 3.01159-2.450818 5.461385-5.462408 5.461385L588.757175 434.04351c-3.010567 0-5.461385-2.450818-5.461385-5.461385L583.295789 90.240257z"
                        fill="#FF9000" p-id="2913"></path>
                    <path
                        d="M969.676767 566.196343c0-10.172687-8.246825-18.419512-18.419512-18.419512l-67.50444 0c-10.172687 0-18.419512 8.246825-18.419512 18.419512s8.246825 18.419512 18.419512 18.419512l49.084928 0 0 71.009264L779.708158 655.625118c-10.172687 0-18.419512 8.246825-18.419512 18.419512s8.246825 18.419512 18.419512 18.419512l171.549098 0c10.172687 0 18.419512-8.246825 18.419512-18.419512 0-0.076748-0.010233-0.151449-0.011256-0.228197 0.001023-0.076748 0.011256-0.150426 0.011256-0.228197L969.676767 566.196343z"
                        fill="#FF9000" p-id="2914"></path>
                    <path
                        d="M630.202099 933.142689l-44.813648 0 0-51.2922c0-10.172687-8.246825-18.419512-18.419512-18.419512s-18.419512 8.246825-18.419512 18.419512l0 69.711711c0 10.172687 8.246825 18.419512 18.419512 18.419512l63.23316 0c10.172687 0 18.419512-8.246825 18.419512-18.419512S640.374786 933.142689 630.202099 933.142689z"
                        fill="#FF9000" p-id="2915"></path>
                    <path
                        d="M834.04981 790.359752c0-10.172687-8.246825-18.419512-18.419512-18.419512L699.257871 771.940241c-10.172687 0-18.419512 8.246825-18.419512 18.419512l0 163.013701c0 10.172687 8.246825 18.419512 18.419512 18.419512s18.419512-8.246825 18.419512-18.419512L717.677383 808.779264 815.630299 808.779264C825.802986 808.779264 834.04981 800.532439 834.04981 790.359752z"
                        fill="#FF9000" p-id="2916"></path>
                    <path
                        d="M951.060781 723.425294c-10.172687 0-18.419512 8.246825-18.419512 18.419512l0 194.301288L765.943666 936.146093c-10.172687 0-18.419512 8.246825-18.419512 18.419512s8.246825 18.419512 18.419512 18.419512l185.117115 0c10.172687 0 18.419512-8.246825 18.419512-18.419512L969.480292 741.844805C969.480292 731.672118 961.234491 723.425294 951.060781 723.425294z"
                        fill="#FF9000" p-id="2917"></path>
                    <path
                        d="M655.979182 623.620194c-10.172687 0-18.419512 8.246825-18.419512 18.419512l0 59.869552c0 10.172687 8.246825 18.419512 18.419512 18.419512s18.419512-8.246825 18.419512-18.419512l0-59.869552C674.398694 631.867018 666.151869 623.620194 655.979182 623.620194z"
                        fill="#FF9000" p-id="2918"></path>
                  </svg>
                  <svg t="1730293533050" class="icon" viewBox="0 0 1024 1024" version="1.1"
                       xmlns="http://www.w3.org/2000/svg" p-id="4263" width="16" height="16">
                    <path
                        d="M664.250054 368.541681c10.015098 0 19.892049 0.732687 29.67281 1.795902-26.647917-122.810047-159.358451-214.077703-310.826188-214.077703-169.353083 0-308.085774 114.232694-308.085774 259.274068 0 83.708494 46.165436 152.460344 123.281791 205.78483l-30.80868 91.730191 107.688651-53.455469c38.558178 7.53665 69.459978 15.308661 107.924012 15.308661 9.66308 0 19.230993-0.470721 28.752858-1.225921-6.025227-20.36584-9.521864-41.723264-9.521864-63.862493C402.328693 476.632491 517.908058 368.541681 664.250054 368.541681zM498.62897 285.87389c23.200398 0 38.557154 15.120372 38.557154 38.061874 0 22.846334-15.356756 38.156018-38.557154 38.156018-23.107277 0-46.260603-15.309684-46.260603-38.156018C452.368366 300.994262 475.522716 285.87389 498.62897 285.87389zM283.016307 362.090758c-23.107277 0-46.402843-15.309684-46.402843-38.156018 0-22.941502 23.295566-38.061874 46.402843-38.061874 23.081695 0 38.46301 15.120372 38.46301 38.061874C321.479317 346.782098 306.098002 362.090758 283.016307 362.090758zM945.448458 606.151333c0-121.888048-123.258255-221.236753-261.683954-221.236753-146.57838 0-262.015505 99.348706-262.015505 221.236753 0 122.06508 115.437126 221.200938 262.015505 221.200938 30.66644 0 61.617359-7.609305 92.423993-15.262612l84.513836 45.786813-23.178909-76.17082C899.379213 735.776599 945.448458 674.90216 945.448458 606.151333zM598.803483 567.994292c-15.332197 0-30.807656-15.096836-30.807656-30.501688 0-15.190981 15.47546-30.477129 30.807656-30.477129 23.295566 0 38.558178 15.286148 38.558178 30.477129C637.361661 552.897456 622.099049 567.994292 598.803483 567.994292zM768.25071 567.994292c-15.213493 0-30.594809-15.096836-30.594809-30.501688 0-15.190981 15.381315-30.477129 30.594809-30.477129 23.107277 0 38.558178 15.286148 38.558178 30.477129C806.808888 552.897456 791.357987 567.994292 768.25071 567.994292z"
                        fill="#5D5D5D" p-id="4264"></path>
                  </svg>
                  <p>微信扫一扫关注</p>
                  <p>快速预约挂号</p>
                </div>
                <div class="item">
                  <svg t="1730293486343" class="icon" viewBox="0 0 1024 1024" version="1.1"
                       xmlns="http://www.w3.org/2000/svg" p-id="3175" width="128" height="128">
                    <path
                        d="M149.897707 387.566843l154.232099 0c49.484303 0 89.577425-40.093122 89.577425-89.577425L393.707231 143.757319C393.707231 94.273016 353.614109 54.179894 304.491005 54.179894L149.897707 54.179894c-49.484303 0-89.577425 40.093122-89.577425 89.577425l0 154.232099C60.320282 347.473721 100.774603 387.566843 149.897707 387.566843zM136.533333 143.757319c0-7.223986 6.140388-13.364374 13.364374-13.364374l154.232099 0c7.223986 0 13.364374 6.140388 13.364374 13.364374l0 154.232099c0 7.223986-6.140388 13.364374-13.364374 13.364374L149.897707 311.353792c-7.223986 0-13.364374-6.140388-13.364374-13.364374L136.533333 143.757319z"
                        fill="#575B66" p-id="3176"></path>
                    <path
                        d="M304.491005 628.486772 149.897707 628.486772c-49.484303 0-89.577425 40.093122-89.577425 89.577425l0 154.232099c0 49.484303 40.093122 89.577425 89.577425 89.577425l154.232099 0c49.484303 0 89.577425-40.093122 89.577425-89.577425l0-154.232099C393.707231 668.579894 353.614109 628.486772 304.491005 628.486772zM317.49418 872.296296c0 7.223986-6.140388 13.364374-13.364374 13.364374L149.897707 885.66067c-7.223986 0-13.364374-6.140388-13.364374-13.364374l0-154.232099c0-7.223986 6.140388-13.364374 13.364374-13.364374l154.232099 0c7.223986 0 13.364374 6.140388 13.364374 13.364374L317.49418 872.296296z"
                        fill="#575B66" p-id="3177"></path>
                    <path
                        d="M878.797884 54.179894l-154.232099 0c-49.484303 0-89.577425 40.093122-89.577425 89.577425l0 154.232099c0 49.484303 40.093122 89.577425 89.577425 89.577425l154.232099 0c49.484303 0 89.577425-40.093122 89.577425-89.577425L968.375309 143.757319C968.014109 94.273016 927.920988 54.179894 878.797884 54.179894zM891.801058 297.989418c0 7.223986-6.140388 13.364374-13.364374 13.364374l-154.232099 0c-7.223986 0-13.364374-6.140388-13.364374-13.364374L710.840212 143.757319c0-7.223986 6.140388-13.364374 13.364374-13.364374l154.232099 0c7.223986 0 13.364374 6.140388 13.364374 13.364374L891.801058 297.989418z"
                        fill="#575B66" p-id="3178"></path>
                    <path
                        d="M673.997884 552.273721c19.865961 0 36.119929-15.892769 35.75873-36.119929 0-19.865961-15.892769-36.119929-36.119929-36.119929l-126.058554 0L547.578131 338.443739c0-19.865961-15.892769-36.119929-36.119929-35.75873-19.865961 0-36.119929 15.892769-36.119929 36.119929L475.338272 480.395062 96.440212 480.395062c-19.865961 0-36.119929 15.892769-36.119929 36.119929 0 19.865961 15.892769 36.119929 36.119929 36.119929l379.620459 0 0 169.04127c0 19.865961 15.892769 36.119929 36.119929 36.119929s36.119929-15.892769 36.119929-36.119929l0-169.04127L673.997884 552.634921z"
                        fill="#575B66" p-id="3179"></path>
                    <path
                        d="M932.255379 552.273721c19.865961 0 36.119929-15.892769 35.75873-36.119929 0-19.865961-15.892769-36.119929-36.119929-36.119929l-79.825044 0c-19.865961 0-36.119929 15.892769-36.119929 36.119929 0 19.865961 15.892769 36.119929 36.119929 36.119929L932.255379 552.273721z"
                        fill="#575B66" p-id="3180"></path>
                    <path
                        d="M511.8194 166.874074c19.865961 0 36.119929-15.892769 36.119929-36.119929L547.93933 88.855026c0-19.865961-15.892769-36.119929-36.119929-35.75873-19.865961 0-36.119929 15.892769-36.119929 36.119929l0 41.899118C476.06067 150.620106 491.953439 166.874074 511.8194 166.874074z"
                        fill="#575B66" p-id="3181"></path>
                    <path
                        d="M511.8194 849.179541c-19.865961 0-36.119929 15.892769-36.119929 36.119929l0 41.899118c0 19.865961 15.892769 36.119929 36.119929 36.119929s36.119929-15.892769 36.119929-36.119929l0-42.260317C547.93933 865.07231 531.685362 849.179541 511.8194 849.179541z"
                        fill="#575B66" p-id="3182"></path>
                    <path
                        d="M892.884656 871.573898c0 7.223986-6.140388 13.003175-13.003175 13.003175l-38.648325 0 0 75.129453 38.648325 0c48.761905 0 88.493827-39.731922 88.493827-88.493827l0-43.705115-75.129453 0L893.245855 871.573898z"
                        fill="#575B66" p-id="3183"></path>
                    <path
                        d="M879.520282 631.015168l-152.426102 0c-48.761905 0-88.493827 39.731922-88.493827 88.493827l0 152.426102c0 48.761905 39.731922 88.493827 88.493827 88.493827l38.648325 0L765.742504 884.938272l-38.648325 0c-7.223986 0-13.003175-6.140388-13.003175-13.003175l0-152.426102c0-7.223986 6.140388-13.003175 13.003175-13.003175l152.426102 0c7.223986 0 13.003175 6.140388 13.003175 13.003175l0 33.591534L968.014109 753.100529l0-33.591534C968.014109 670.74709 928.282187 631.015168 879.520282 631.015168z"
                        fill="#575B66" p-id="3184"></path>
                  </svg>
                  <svg t="1730293620626" class="icon" viewBox="0 0 1024 1024" version="1.1"
                       xmlns="http://www.w3.org/2000/svg" p-id="5424" width="16" height="16">
                    <path
                        d="M256 85.333333h512c64.8 0 117.333333 52.533333 117.333333 117.333334v618.666666c0 64.8-52.533333 117.333333-117.333333 117.333334H256c-64.8 0-117.333333-52.533333-117.333333-117.333334V202.666667c0-64.8 52.533333-117.333333 117.333333-117.333334z m0 64a53.333333 53.333333 0 0 0-53.333333 53.333334v618.666666a53.333333 53.333333 0 0 0 53.333333 53.333334h512a53.333333 53.333333 0 0 0 53.333333-53.333334V202.666667a53.333333 53.333333 0 0 0-53.333333-53.333334H256z m170.666667 618.666667a32 32 0 0 1 0-64h170.666666a32 32 0 0 1 0 64H426.666667z"
                        fill="#000000" p-id="5425"></path>
                  </svg>
                  <p>扫一扫下载</p>
                  <p>预约挂号APP</p>
                </div>
              </div>
            </div>
            <p class="tip">尚医通指定平台</p>
            <p class="tip">尚医通指定平台</p>
          </el-col>
        </el-row>
      </div>
      <template #footer>
        <el-button @click="userStore.visiable=false">关闭窗口</el-button>
      </template>
    </el-dialog>
  </div>
</template>
<script setup lang="ts">
import {computed, ref} from 'vue'
import useUserStore from "@/store/modules/user.ts";
import {User, Lock} from "@element-plus/icons-vue";
import {ElMessage} from "element-plus";
import CountDown from '@/components/countdown/index.vue'
import {LoginData, WXLoginResponseData} from "@/api/hospital/type.ts";
import {reqWxLogin} from "@/api/hospital";
import {useRoute, useRouter} from "vue-router";

const $router = useRouter()
const $route = useRoute()
const userStore = useUserStore()
//0 手机号登陆 1 微信登录二维码
const scene = ref<number>(0);
//是显示开启倒计时按钮
const codeFlag = ref<boolean>(false);
//手机号登陆数据
const loginParam = ref<LoginData>({
  phone: '',
  code: ''
})
//登录表单form实例
const form = ref()

const isPhone = computed(() => {
  const reg = /^(13[0-9]|14[579]|15[0-35-9]|166|17[01345678]|18[0-9]|19[89])\d{8}$/;
  return reg.test(loginParam.value.phone)
})
//获取验证码
const getCode = async () => {
  try {
    codeFlag.value = true
    await userStore.getCode(loginParam.value.phone);
    loginParam.value.code = userStore.code
  } catch (e ) {
    ElMessage.error("获取验证码失败，" + e.message)
  }
}

//切换登陆方式
const changeScene = async (type: number) => {
  scene.value = type;
  if(type===1){
    const redirectUrl = encodeURIComponent(window.location.origin+'/wxlogin')
    const result:WXLoginResponseData = await reqWxLogin(redirectUrl);
    console.log(result)
    //微信登陆
    //@ts-ignore
    new WxLogin({
      self_redirect:true,
      id:"login_container",//显示二维码的容器id
      appid: result.data.appid,
      scope: result.data.scope,//授权作用域，
      redirect_uri: "http%3A%2F%2Fforum.atguigu.cn%2Fapi%2FweixinPc%2Fcallback",//填写回调路径
      state: 'syt-'+redirectUrl,//重定向携带的信息
      style: "black",
    });
  }
}
//子组件绑定的自定义事件
const getCodeFlag = (flag: boolean) => {
  console.log('getCodeFlag', flag)
  codeFlag.value = flag
}
/**
 * 手机号登陆
 */
const phoneLoginSubmit = async () => {
  form.value.validate(async (valid: boolean) => {
    if (!valid) {
      return
    }
    try {
      await userStore.phoneLogin(loginParam.value)
      ElMessage.success("登陆成功")
      userStore.visiable = false
      const redirect = $route.query.redirect
      if(redirect){
        $router.push(redirect as string)
      }else {
        $router.push("/home")
      }
    } catch (e) {
      ElMessage.error("登陆失败，" + e.message)
    }
  })

}
//表单校验规则对象
const rules = ref({
  phone: [
    {required: true, message: '请输入手机号', trigger: 'blur'},
    {
      pattern: /^(13[0-9]|14[579]|15[0-35-9]|166|17[01345678]|18[0-9]|19[89])\d{8}$/,
      message: '手机号格式不正确',
      trigger: 'blur'
    }
  ],
  code: [
    {required: true, message: '请输入验证码', trigger: 'blur'},
    {
      trigger: 'blur', validator: (rule: any, value: string, callback: any) => {
        console.log(rule,value,callback)
        if (value.length !== 6) {
          return callback(new Error('验证码长度必须是六位'))
        } else {
          callback()
        }
      }
    }
  ]
})

</script>

<style scoped lang="scss">
.login {
  :deep(.el-dialog__body) {
    border-top: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
  }

  .content {
    margin: 20px 0;

    .loginDiv {
      border: #ccc 1px solid;
      padding: 20px;

      .bottom {
        display: flex;
        flex-direction: column;
        align-items: center;

        p {
          margin: 5px 0;
        }
      }
    }
    .wxDiv{
      .bottom{
        display: flex;
        flex-direction: column;
        align-items: center;
        p{
          margin: 10px;
        }
      }
    }
    .leftContent {
      .top {
        margin: 0 20px;
        display: flex;
        justify-content: space-between;

        .item {
          display: flex;
          flex-direction: column;
          align-items: center;

          p {
            margin: 10px 0;
          }
        }
      }
    }

    .tip {
      text-align: center;
      margin-bottom: 10px;
      font-size: 20px;
      font-weight: 900;
    }
  }
}
</style>
